package com.smartHire.service.impl;

import com.smartHire.dao.CartDao;
import com.smartHire.domain.Cart;
import com.smartHire.service.CartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("cartService")
public class CartServiceImpl implements CartService {

    @Resource(name = "cartDao")
    private CartDao cartDao;

    @Override
    public int addCart(Cart cart) {
        try {
            int nums = cartDao.insertCart(cart);
            return nums;
        }catch (Exception e)
        {
            e.printStackTrace();
        }

        return 0;
    }

    @Override
    public int deleteCart(Cart cart) {
        try {
            int nums = cartDao.deleteCart(cart);
            return nums;

        }catch (Exception e)
        {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int updateCart(Cart cart) {
        try {
            int nums = cartDao.updateCart(cart);
            return nums;

        }catch (Exception e)
        {
            e.printStackTrace();
        }

        return 0;
    }

    @Override
    public List<Cart> queryCartByU_id(Cart cart) {
        try {
            List<Cart> carts = cartDao.selectCartByU_id(cart);
            return  carts;
        }catch (Exception e)
        {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Cart queryCartByC_id(Cart cart) {
        try {
            cart = cartDao.selectCartByC_id(cart);
            return  cart;
        }catch (Exception e)
        {
            e.printStackTrace();
        }
        return null;
    }
}
